var rootUrl = "capi/V2/KSMap/ksCircuit/" 
var netTool
// var checkdata = require('../utils/dataCheek')
var page = {
	pageSize: 10,
	total: 0,
	currentPage: 1
}
/**
 * wx_synchronization_flag = 1表示已经拉取用户信息
 */
import mNetTool from "../tools/NetTool.js"
function KMSwats(_netTool) {
	netTool = mNetTool 
	this.updatePoint = function(data,fn){
		netTool.getAjaxUrlValue( 'capi/V2/KMSpoints/kmsPoints/update', {
			...data
		}, function(res) { 
			typeof fn == 'function' && fn(res);
		})
	}
	/**获取点位
	 * @param {Object} data
	 * @param {Object} fn
	 */
	this.getPoints = function(data,fn){
		netTool.getAjaxUrlValue( 'capi/V2/KMSpoints/kmsPoints/list', {
			...data
		}, function(res) { 
			typeof fn == 'function' && fn(res);
		})
	}
	/**删除一点位
	 * @param {Object} data
	 * @param {Object} fn
	 */
	this.delPoint = function(data,fn){
		netTool.getAjaxUrlValue( 'capi/V2/KMSpoints/kmsPoints/del', {
			...data
		}, function(res) { 
			typeof fn == 'function' && fn(res);
		})
	}
	/**存一个标记点
	 * @param {Object} data
	 * @param {Object} fn
	 */
	this.savePoint = function(data,fn){
		netTool.getAjaxUrlValue( 'capi/V2/KMSpoints/kmsPoints/save', {
			...data
		}, function(res) { 
			typeof fn == 'function' && fn(res);
		})
	}
	/**附近路线
	 * @param {Object} data
	 * @param {Object} fn
	 */
	this.getNearWays = function(data,fn){
		netTool.getAjaxUrlValue(rootUrl + 'list', {
			
		}, function(res) { 

		})
	}


	/**
	 * @param {Object} data owner_id:用户id					
					        route_line_id:对应的路线id
	 * @param {Object} fn
	 */
	this.delMyWays = function(data,fn){ 
		netTool.getAjaxUrlValue( rootUrl + 'del',{
			...data
		},res=>{ 
			console.log('del',res)
			typeof fn == 'function' && fn(res);
		})
	}
	/**获取的我的路线
	status:1
	 * @param {Object} data 
	 * @param {Object} fn
	 */
	this.getMyWays = function(data,fn){
		netTool.getAjaxUrlValue(rootUrl + 'list',{
			status:1,
			...data
		},res=>{
			typeof fn == 'function' && fn(res);
		})
	}
	// 存一个路线  
	this.saveRoute = function(data,fn){
		netTool.getAjaxUrlValue(rootUrl + 'save', {
			...data
		}, function(res) {  
			typeof fn == 'function' && fn(res);
		})
	}
	this.updateRoute = function(data,fn){
		netTool.getAjaxUrlValue(rootUrl + 'update', {
			...data
		}, function(res) {  
			typeof fn == 'function' && fn(res);
		})
	}
	this.list = function(data, fn) {
		netTool.getAjaxUrlValue(rootUrl + 'list', {
			...data
		}, function(res) {
			typeof fn == 'function' && fn(res);
		})
	}
	 
 } 
module.exports = KMSwats;
